package com.paper.tiger.easy.rpc.center;

import com.paper.tiger.easy.rpc.core.RegisterServerMesage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * [简要描述]:
 * [详细描述]:
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/5/28 17:33
 * @since JDK 1.8
 */
public class ServerMap
{

    /**
     * key 为全类名+“-”+ 方法名
     *
     *
     */
    private static final Map<String, RegisterServerMesage> map  = new HashMap<>();

    /**
     * 注册服务
     * @param interfaceName
     * @param mesage
     */
    public static void registerServer(String interfaceName,RegisterServerMesage mesage){
        map.put(interfaceName, mesage);
    }


    public static RegisterServerMesage getByKey(String key){
        return map.get(key);
    }

    public static List<RegisterServerMesage> list() {
        List<RegisterServerMesage> mesages = new ArrayList<>();
        map.forEach((k,v)->{
            mesages.add(v);
        });
        return mesages;
    }


}
